package domain.items;

import interfaces.GUIVisitor;
import org.compass.annotations.SearchableProperty;

public abstract class Item  {

	/**
	 * macros for Type Identification
	 */
	public final static int TOPIC = 0;
	public final static int FORUM_THREAD = 1;
	public final static int POST = 2;
	public final static int PACKET = 3;

	/**
	 * unique id for each item in the repository.
	 */
	protected long _id;

	/**
	 * name = title of the post\thread\topic. doesn't have to be unique.
	 */
	@SearchableProperty(name = "contents")
	protected String _name;

	/**
	 * sometimes we need to check what is the actual instance of the item
	 * instead of using "instanceof", we'll check the value of this field
	 */
	protected int _type;

	/**
	 * each item has one father in the tree-like structure of the forum.
	 */
	protected Item _father;

	/**
	 * Constructor.
	 * @param father
	 */
	protected Item(Item father){
		this._father = father;
	}

	/**
	 * this constructor is used only to create clones
	 * and should not be used for anything else
	 * @param father
	 */
	protected Item() {

	}

	/**
	 * getters
	 */
	public long getId() {
		return _id;
	}

	public void setId(long id){
		this._id = id;
	}

	public String getName() {
		return _name;
	}

	public void setName(String name){
		this._name = name;
	}

	public int getType() {
		return this._type;
	}

	public Item getFather() {
		return this._father;

	}

	public void setFather(Item father) {
		this._father = father;

	}

	public String toString(){
		return this._name;
	}

	/**
	 * this method should be override by classes who need to be displayed by the gui
	 * @param visitor
	 */
	public void accept(GUIVisitor visitor) {
		System.err.println("Didnt wanna call this one...");
	}

	public Item convertToPacket() {
		return null;
	}

}
